#@layout()
#define main()
<link href="#(base)/fslayui/plugins/formSelect/formSelects.css" rel="stylesheet"/>
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-form-item">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-mid">选择训练批次：</label>
                    <div class="layui-input-inline" style="width: 200px;">
                        <select xm-select="train" xm-select-search="#(base)/train/getTrainList" xm-select-radio>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-mid">选择学生：</label>
                    <div class="layui-input-inline" style="width: 200px;">
                        <select id="trainstudent" xm-select="trainstudent" xm-select-search="#(base)/train/getTrainStudentList" xm-select-radio>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>提交成绩</legend>
        </fieldset>

        <iframe src="" id="showEditTrainResult" frameborder="no" style="width: 100%;height: 500px;" ></iframe>

    </div>
</div>
<script>

    var base = '#(base)';
    var trainid = '';
    layui.use(['jquery', 'form', 'formSelects'], function(){
        var $ = layui.jquery,
            form = layui.form,
            formSelects = layui.formSelects;
        formSelects.render("train");
        formSelects.render("trainstudent");
        formSelects.on('train', function(id, vals, val, isAdd, isDisabled){
            //id:           点击select的id
            //vals:         当前select已选中的值
            //val:          当前select点击的值
            //isAdd:        当前操作选中or取消
            //isDisabled:   当前选项是否是disabled

            //如果return false, 那么将取消本次操作\
            if(isAdd){
                trainid = val.value;
                layui.formSelects.config('trainstudent', {
                    searchUrl: base+'/train/getTrainStudentList?trainid='+trainid
                });
            }else{
                trainid = "";
                layui.formSelects.value('trainstudent', []);
                $('#showEditTrainResult').attr("src","");
                layui.formSelects.config('trainstudent', {
                    searchUrl: base+'/train/getTrainStudentList'
                });
            }
            console.log(val+'------'+isAdd);
            return true;
        });

        formSelects.on('trainstudent', function(id, vals, val, isAdd, isDisabled){
            //id:           点击select的id
            //vals:         当前select已选中的值
            //val:          当前select点击的值
            //isAdd:        当前操作选中or取消
            //isDisabled:   当前选项是否是disabled

            //如果return false, 那么将取消本次操作\
            if(isAdd){
                $('#showEditTrainResult').attr("src",base+'/train/showEditTrainResult?newid='+trainid+'-'+val.value);
            }else{
                $('#showEditTrainResult').attr("src","");
            }
            console.log(val);
            return true;
        });
    });
</script>
#end